/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nxlv2.nomad.businessobjects;



/**
 *
 * @author Nastasia
 */
public enum TypeDemande {

    PROSPECT(1,"Prospect"),
    INTERET(2,"Intérêt"),
    DEVIS(3,"Devis"),
    COMMANDE(4,"Commande");

    private final int id;
    private final String libelle;

    /**
     *
     * @param libelle
     */
    TypeDemande(int id, String libelle) {
        this.id = id;
        this.libelle = libelle;
    }

    public static TypeDemande getByID(int id){
        for (TypeDemande type : TypeDemande.values()) {
            if ( type.getId() == id ) {
                return type;
            }
        }
        return null; // throw exception ?
    }
    
    public static TypeDemande getByLibelle(String lib) {
        for (TypeDemande type : TypeDemande.values()) {
            if (type.getLibelle().equals(lib)) {
                return type;
            }
        }
        return null; // throw exception ?
    }

    /**
     * 
     * @return id
     */
    public int getId(){
        return this.id;
    }
    /**
     *
     * @return libelle
     */
    public String getLibelle() {
        return this.libelle;
    }

    /**
     *
     * @return String
     */
    @Override
    public String toString() {
        return "TypeDemande{" + "id="+ id + ", libelle=" + libelle + '}';
    }

    public String toJSONString(){
        return "{\"id\":\""+ id +"\",\"libelle\":\""+ libelle +"\"}";
    }
}

